<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
		<title>父爱力 大挑战</title>
		<link rel="stylesheet" href="./css/common.css">
		<link rel="stylesheet" href="./css/index.css">

		<!--<link rel="stylesheet" href="./css/nativeShare.css"/>-->
		<link rel="stylesheet" type="text/css" href="./css/animate.css">
		<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
	</head>

	<body>
		<audio src="./audio.mp3" autoplay loop id="audio"></audio>
		<div class="hidden">
			<script type="text/javascript">
				var images = new Array()

				function preload() {
					for(i = 0; i < preload.arguments.length; i++) {
						images[i] = new Image()
						images[i].src = preload.arguments[i]
					}
				}
				preload(
					'./images/title-1.png',
					'./images/title-2.png',
					'./images/title-3.png',
					'./images/title-4.png',
					'./images/title-5.png',
					'./images/title-8.png',
					'./images/title-9.png',
					'./images/title-10.png',
					'./images/title-11.png',
					'./images/title-12.png',
					'./images/1-1.png', './images/1-2.png', './images/1-3.png',
					'./images/2-1.png', './images/2-2.png', './images/2-3.png',
					'./images/3-1.png', './images/3-2.png', './images/3-3.png',
					'./images/4-1.png', './images/4-2.png', './images/4-3.png',
					'./images/5-1.png', './images/5-2.png', './images/5-3.png',
					'./images/8-1.png', './images/8-2.png', './images/8-3.png',
					'./images/9-1.png', './images/9-2.png', './images/9-3.png',
					'./images/10-1.png', './images/10-2.png', './images/10-3.png',
					'./images/11-1.png', './images/11-2.png', './images/11-3.png',
					'./images/12-1.png', './images/12-2.png', './images/12-3.png',
					'./images/13-2.png', './images/13-3.png', './images/13.png',
					'./images/answer1.png', './images/answer2.png', './images/answer3.png',
					'./images/cat.png', './images/common-bg.png', './images/common-bg2.png',
					'./images/continue-btn.png', './images/home-word.png', './images/share-btn.png'
				)
			</script>
		</div>
		<div class='wrapper'>
			<div class="question-title title1"></div>
			<div class="answer-top">
				<div class='answer a-answer1' data-score='1'></div>
				<div class='answer a-answer2' data-score='2'></div>
				<div class='answer a-answer3' data-score='3'></div>
			</div>
		</div>

		<div class='container' style="display:none;">
			<div class="answer-title type4"></div>
			<div class="results">
				<div class='code'>
					<img src="./images/code.jpg" alt="">
				</div>
				<div class="right">
					<div class='test' style="display: none"></div>
					<div class="again" style="display: none">
						<a href="./index.html"></a>
					</div>
					<div class='share' id="nativeShare"></div>
				</div>

			</div>
		</div>
		<div class="share-tips" style="display:none;"></div>
		<script src="./js/zpeto.min.js"></script>
		<script>
			//UC和QQ浏览器弹出分享
			var nativeShare = function(elementNode, config) {
				if(!document.getElementById(elementNode)) {
					return false;
				}

				var qApiSrc = {
					lower: "//3gimg.qq.com/html5/js/qb.js",
					higher: "//jsapi.qq.com/get?api=app.share"
				};
				var bLevel = {
					qq: {
						forbid: 0,
						lower: 1,
						higher: 2
					},
					uc: {
						forbid: 0,
						allow: 1
					}
				};
				var UA = navigator.appVersion;
				var isqqBrowser = (UA.split("MQQBrowser/").length > 1) ? bLevel.qq.higher : bLevel.qq.forbid;
				var isucBrowser = (UA.split("UCBrowser/").length > 1) ? bLevel.uc.allow : bLevel.uc.forbid;
				var version = {
					uc: "",
					qq: ""
				};
				var isWeixin = false;

				config = config || {};
				this.elementNode = elementNode;
				this.url = config.url || document.location.href || '';
				this.title = config.title || document.title || '';
				this.desc = config.desc || document.title || '';
				this.img = config.img || document.getElementsByTagName('img').length > 0 && document.getElementsByTagName('img')[0].src || '';
				this.img_title = config.img_title || document.title || '';
				this.from = config.from || window.location.host || '';
				this.ucAppList = {
					sinaWeibo: ['kSinaWeibo', 'SinaWeibo', 11, '新浪微博'],
					weixin: ['kWeixin', 'WechatFriends', 1, '微信好友'],
					weixinFriend: ['kWeixinFriend', 'WechatTimeline', '8', '微信朋友圈'],
					QQ: ['kQQ', 'QQ', '4', 'QQ好友'],
					QZone: ['kQZone', 'QZone', '3', 'QQ空间']
				};

				this.share = function(to_app) {
					var title = this.title,
						url = this.url,
						desc = this.desc,
						img = this.img,
						img_title = this.img_title,
						from = this.from;
					if(isucBrowser) {
						to_app = to_app == '' ? '' : (platform_os == 'iPhone' ? this.ucAppList[to_app][0] : this.ucAppList[to_app][1]);
						if(to_app == 'QZone') {
							B = "mqqapi://share/to_qzone?src_type=web&version=1&file_type=news&req_type=1&image_url=" + img + "&title=" + title + "&description=" + desc + "&url=" + url + "&app_name=" + from;
							k = document.createElement("div"), k.style.visibility = "hidden", k.innerHTML = '<iframe src="' + B + '" scrolling="no" width="1" height="1"></iframe>', document.body.appendChild(k), setTimeout(function() {
								k && k.parentNode && k.parentNode.removeChild(k)
							}, 5E3);
						}
						if(typeof(ucweb) != "undefined") {
							ucweb.startRequest("shell.page_share", [title, title, url, to_app, "", "@" + from, ""])
						} else {
							if(typeof(ucbrowser) != "undefined") {
								ucbrowser.web_share(title, title, url, to_app, "", "@" + from, '')
							} else {}
						}
					} else {
						if(isqqBrowser && !isWeixin) {
							to_app = to_app == '' ? '' : this.ucAppList[to_app][2];
							var ah = {
								url: url,
								title: title,
								description: desc,
								img_url: img,
								img_title: img_title,
								to_app: to_app, //微信好友1,腾讯微博2,QQ空间3,QQ好友4,生成二维码7,微信朋友圈8,啾啾分享9,复制网址10,分享到微博11,创意分享13
								cus_txt: "请输入此时此刻想要分享的内容"
							};
							ah = to_app == '' ? '' : ah;
							if(typeof(browser) != "undefined") {
								if(typeof(browser.app) != "undefined" && isqqBrowser == bLevel.qq.higher) {
									browser.app.share(ah)
								}
							} else {
								if(typeof(window.qb) != "undefined" && isqqBrowser == bLevel.qq.lower) {
									window.qb.share(ah)
								} else {}
							}
						} else {}
					}
				};

				this.isloadqqApi = function() {
					if(isqqBrowser) {
						var b = (version.qq < 5.4) ? qApiSrc.lower : qApiSrc.higher;
						var d = document.createElement("script");
						var a = document.getElementsByTagName("body")[0];
						d.setAttribute("src", b);
						a.appendChild(d)
					}
				};

				this.getPlantform = function() {
					ua = navigator.userAgent;
					if((ua.indexOf("iPhone") > -1 || ua.indexOf("iPod") > -1)) {
						return "iPhone"
					}
					return "Android"
				};

				this.is_weixin = function() {
					var a = UA.toLowerCase();
					if(a.match(/MicroMessenger/i) == "micromessenger") {
						return true
					} else {
						return false
					}
				};

				this.getVersion = function(c) {
					var a = c.split("."),
						b = parseFloat(a[0] + "." + a[1]);
					return b
				};

				this.init = function() {
					platform_os = this.getPlantform();
					version.qq = isqqBrowser ? this.getVersion(UA.split("MQQBrowser/")[1]) : 0;
					version.uc = isucBrowser ? this.getVersion(UA.split("UCBrowser/")[1]) : 0;
					isWeixin = this.is_weixin();
					if((isqqBrowser && version.qq < 5.4 && platform_os == "iPhone") || (isqqBrowser && version.qq < 5.3 && platform_os == "Android")) {
						isqqBrowser = bLevel.qq.forbid
					} else {
						if(isqqBrowser && version.qq < 5.4 && platform_os == "Android") {
							isqqBrowser = bLevel.qq.lower
						} else {
							if(isucBrowser && ((version.uc < 10.2 && platform_os == "iPhone") || (version.uc < 9.7 && platform_os == "Android"))) {
								isucBrowser = bLevel.uc.forbid
							}
						}
					}
					this.isloadqqApi();
					var _this = this;
					if(isqqBrowser || isucBrowser) {
						document.getElementById('nativeShare').onclick = function() {
							_this.share("");
						}
					} else {

					}
				};

				this.init();
				return this;
			};

			function getwxConfig() {
				$.ajax({
					url: 'http://m.authlib.cn/tgGetConfig',
					data: {
						url: window.location.href.split('#')[0]
					},
					type: 'get',
					dataType: 'JSON',
					success: function(data) {
						data=JSON.parse(data);
						
						wx.config({
							debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
							appId: 'wx41a373ad66496ead', // 必填，公众号的唯一标识
							timestamp: data.timestamp, // 必填，生成签名的时间戳
							nonceStr: data.nonceStr, // 必填，生成签名的随机串
							signature: data.signature, // 必填，签名
							jsApiList: [
								'onMenuShareTimeline',
								'onMenuShareAppMessage',
								'startRecord',
								'stopRecord',
								'onVoiceRecordEnd',
								'playVoice',
								'pauseVoice',
								'stopVoice',
								'onVoicePlayEnd',
								'uploadVoice',
								'downloadVoice',
								'chooseImage',
								'previewImage',
								'uploadImage',
								'downloadImage'
							]
						});
					},
					error: function(error) {
						
					}
				});

			}
            getwxConfig();
			wx.ready(function() {
				console.log("JsSDK Success!")
				wx.onMenuShareAppMessage({
					title: "父爱力  大挑战", // 分享标题
					desc: "参与游戏测试，凭测试结果，父亲节双重厚礼任你享！送给父亲、自己和孩子！", // 分享描述
					link: 'http://m.authlib.cn/sport/index.html', // 分享链接
					imgUrl: "http://m.authlib.cn/sport/images/logo.jpg", // 分享图标
					type: 'link', //
					success: function() {
						console.log("分享朋友成功")
					}
				});

				wx.onMenuShareTimeline({
					title: "父爱力  大挑战", // 分享标题
					link: 'http://m.authlib.cn/sport/index.html', // 分享链接
					imgUrl: "http://m.authlib.cn/sport/images/logo.jpg", // 分享图标
					success: function() {
						console.log("分享朋友圈成功")
					}
				});
			});
		</script>
		<script>
			+ function() {
				var hasVisited = localStorage.getItem('sp-first');
				if(!hasVisited) {
					setTimeout(function() {
						window.location.href = 'index.html';
					}, 0)
					return;
				}
				document.body.addEventListener('touchstart', function() {});
				var data = [{
						title: './images/title-1.png',
						q: ['./images/1-1.png', './images/1-2.png', './images/1-3.png']
					},
					{
						title: './images/title-2.png',
						q: ['./images/2-1.png', './images/2-2.png', './images/2-3.png']
					},
					{
						title: './images/title-3.png',
						q: ['./images/3-1.png', './images/3-2.png', './images/3-3.png']
					},
					{
						title: './images/title-4.png',
						q: ['./images/4-1.png', './images/4-2.png', './images/4-3.png']
					},
					{
						title: './images/title-5.png',
						q: ['./images/5-1.png', './images/5-2.png', './images/5-3.png']
					},

					false,

					{
						title: './images/title-8.png',
						q: ['./images/8-1.png', './images/8-2.png', './images/8-3.png']
					},
					{
						title: './images/title-9.png',
						q: ['./images/9-1.png', './images/9-2.png', './images/9-3.png']
					},
					{
						title: './images/title-10.png',
						q: ['./images/10-1.png', './images/10-2.png', './images/10-3.png']
					},
					{
						title: './images/title-11.png',
						q: ['./images/11-1.png', './images/11-2.png', './images/11-3.png']
					},
					{
						title: './images/title-12.png',
						q: ['./images/12-1.png', './images/12-2.png', './images/12-3.png']
					},

					false

				];
				var totalScore = 0,
					totalScore2 = 0;
				var index = 0;

				$('.answer').click(function() {
					index++;
					if(data[index] === false) {
						if(index === 5) {
							computeScore();
						} else {
							computeScore2();
						}
						return;
					}
					if(index < 5) {
						totalScore += parseInt($(this).data('score'));
					} else {
						totalScore2 += parseInt($(this).data('score'));
					}

					update();
				})

				function update() {
					if(index > data.length - 1) {
						return;
					}
					$(".wrapper").show();
					$('.container').hide();
					$('body').attr('class', '');
					$('.question-title').css('background-image', 'url(' + data[index].title + ')').addClass('animated swing');
					$('.answer-title').css('background-image', 'url(' + data[index].title + ')').addClass('animated rubberBand');

					$('.answer').each(function(i) {
						$(this).css('background-image', 'url(' + data[index].q[i] + ')');
						$('.a-answer1,.a-answer3').addClass('animated fadeInLeftBig');
						$('.a-answer2').addClass('animated fadeInRightBig');

					})

					setTimeout(function() {
						$('.question-title').removeClass('animate swing');
						$('.a-answer1,.a-answer3').removeClass('animated fadeInLeftBig');
						$('.a-answer2').removeClass('animated fadeInRightBig');
					}, 1000)

				}

				function computeScore() {
					$(".wrapper").hide();
					$('.container').show();
					$('.test').show()
					$('.again').hide()
					$('.container .share').click(function() {
						$.get('http://139.196.22.22:8088/api.ashx?type=share');
					})
					$.get('http://139.196.22.22:8088/api.ashx?type=score&number=' + totalScore);
					$('body').attr('class', 'diff');
					if(totalScore < 5) {
						$('.container .answer-title').css('background-image', 'url(./images/answer1.png)');
					} else if(totalScore >= 5 && totalScore < 10) {
						$('.container .answer-title').css('background-image', 'url(./images/answer2.png)');
					} else {
						$('.container .answer-title').css('background-image', 'url(./images/answer3.png)');
					}
					// $('.answer-title').addClass('animated pulse');
					$('.container .test').click(function() {
						index++;
						update();
					})
				}

				function computeScore2() {
					$(".wrapper").hide();
					$('.container').show();
					$('.test').hide()
					$('.again').show()
					$('body').attr('class', 'diff');
					$.get('http://139.196.22.22:8088/api.ashx?type=score&number=' + totalScore2);
					if(totalScore2 < 5) {
						$('.container .answer-title').css('background-image', 'url(./images/13.png)');
					} else if(totalScore2 >= 5 && totalScore2 < 10) {
						$('.container .answer-title').css('background-image', 'url(./images/13-2.png)');
					} else {
						$('.container .answer-title').css('background-image', 'url(./images/13-3.png)');
					}

					$('.container .test').click(function() {

					})
				}

				update();

				$('.share-tips').click(function() {
					$('.share-tips').hide()
				})

				function audioAutoPlay(id) {

					var audio = document.getElementById(id),

						play = function() {

							audio.play();

							document.removeEventListener("touchstart", play, false);

						};

					audio.play();
					document.addEventListener("touchstart", play, false);
					var btype = browserType();
					switch(btype) {
						case 'weixin':
							weixinqqbind();
							return;
							break;
						case 'qq':
							weixinqqbind();
							return;
							break;
					}

					var config = {
						url: 'http://www.scgy.org/sport/questions.html',
						title: '父爱力 大挑战',
						desc: '',
						img: '',
						img_title: '',
						from: ''
					};
					var share_obj = new nativeShare('nativeShare', config);
				}
				//根据类型不同绑定事件
				function weixinqqbind() {
					$('.share').click(function() {
						$('.share-tips').show()
					})
					play();
				}

				function ucbind() {

				}

				//判断是微信还是QQ内置浏览器
				function browserType() {
					var ua = navigator.userAgent.toLowerCase();
					if(ua.match(/MicroMessenger/i) == "micromessenger") {
						return 'weixin';
					} else if(ua.match(/QQ/i) == "qq") {
						return 'qq';
					} else if(ua.match(/UCBrowser/i) == "ucbrowser") {
						return 'uc';
					} else if(ua.match(/MQQBrowser/i) == "mqqbrowser") {
						return 'mq';
					}
				}

				audioAutoPlay("audio");

			}()
		</script>
	</body>

</html>